function ProcessEventFormResult (data)
{ 
    
	if (!window.currentevent) return 'No data selected.';
	
    var checkbox    = '<input type="checkbox" (enabled) (checked) onclick="(oncheck)">(label)<br/>';
	registerTemplate ('optionpanel', optionpanel);
	registerTemplate ('swaplink', swaplink);
	registerTemplate ('checkbox', checkbox);
	registerTemplate ('AttachmentRow', AttachmentRow);
	registerTemplate ('CommentRow', CommentRow);
	registerTemplate ('CommentTextbox', CommentTextbox);
	registerTemplate ('Conflictbox', Conflictbox);
	registerTemplate ('Conflictcheck', Conflictcheck);
	registerTemplate ('optioncontent', optioncontent);
	var attacher    = Factory.empty ('AttachmentRow');
	var panel       = Factory.empty ('optionpanel');
	var commenter   = Factory.empty ('CommentRow');
	var commentbox  = Factory.empty ('CommentTextbox');
	var conflictor  = Factory.empty ('Conflictbox');
	var checker     = Factory.empty ('Conflictcheck');
	var optionbody  = Factory.empty ('optioncontent');
	panel.width     = '250';
	
    var Localgetmode = Controller.getmode;
    var ok=''; 
	var CommentText=''; ;
	var dom = window.currentevent;
	var css = window.http.readyState < ReadyState.DONE ? 'color:gray' : 'color:blue';
	var dis = window.http.readyState < ReadyState.DONE ? 'disabled' : '';
	var htm = '';
	
	var nextRow = dom.RowIndex + 1;
	if (nextRow > dom.RowCount - 1) nextRow = 0;
	
	var prevRow = dom.RowIndex - 1;
	if (prevRow < 0) prevRow = dom.RowCount - 1;
	
	var qs = location.href.replace (/\/key\/(\d+)/, '');
	var qs = qs.replace (/\/stamp\/(\d+)/, '');
	qs += '/stamp/' + new Date().getTime();
	
	
	var prevEvt = Controller.eventlist[prevRow];
	var nextEvt = Controller.eventlist[nextRow];
	
	htm += '<table cellspacing=0 bgcolor="#c9d7f1" id="bevelxc9d7f1" class="bevelxc9d7f1" width="100%"><tr><td style="padding:10px 0px 10px 10px">'; 
	
	htm += '<table width="100%" cellspacing=0 cellpadding=0 style="margin-bottom:5px">';
	htm += '<tr>';
	htm += '<td>';
	
	htm += '<a href="' + qs + '" style="color:#336699"><b>&#171; Back to Events</b></a>&nbsp;';
	htm += '<input type="button" '+dis+' value="Delete" onclick="window.currentevent.remove()" class="menubutton"> ';
	htm += '<input type="button" '+dis+' value="Check Availability" onclick="window.currentevent.verify()" class="menubutton"> ' ;
	htm += '<input type="button" '+dis+' value="Save" onclick="window.currentevent.save()" class="menubutton"> ';
	htm += '&nbsp;<a href="javascript:void(0)" onclick=\'window.open("report.html")\'>&nbsp;</a>';
	if (dom.RowCount > 0)
	{
		htm += '<a href="./#' + Controller.createQueryString( {'key': prevEvt.ID} ) + '">&#171; Prev</a>&nbsp;';
//		htm += '<a href="javascript:void(0)" onclick="LoadEventByIndex(' + dom.GridKey + ', ' + prevRow + ')">&#171; Prev</a>&nbsp;';
		htm += '<b>' + (dom.RowIndex + 1) + '</b> of <b>' + dom.RowCount + '</b>&nbsp;';
		htm += '<a href="./#' + Controller.createQueryString( {'key': nextEvt.ID} ) + '">Next &#187;</a>';
//		htm += '<a href="javascript:void(0)" onclick="LoadEventByIndex(' + dom.GridKey + ', ' + nextRow + ')">Next &#187;</a>';
	}
	else
	{
		htm += '<span style="text-decoration: blink;">New Event!</span>';
	}
	
	htm += '&nbsp;&nbsp;';
	
	htm += '</td>';
	htm += '</tr></table>';
		
	htm += '<div id="dcevent" style="overflow:auto;background-color:#ffffff;border:solid 1px;border-color:#999 #fff #fff #999">';
	
	if (dom.ConflictError)
	{
		htm += '<div style="border:solid 1px #DD9999;background-color:#CCCCEE;padding:0px;margin:2px;">';
		htm += '<table cellpadding="0"><tr><td>';
		htm += '<img align=absmiddle src="/webservices/images/explorer/alerticon.jpg">';
		htm += '</td><td style="color:#000066;">';
		htm += 'Unable to save the event because conflicts where found. What would you like to do? &nbsp;';
		htm += '<select onchange="window.currentevent.resolve (this.value)">';
		htm += '<option value="-1">Choose';
		htm += '<option value="0">Override conflicts and save anyway';
		htm += '<option value="1">Save event without approval';
		htm += '<option value="2">Cancel save operation';
		htm += '</select>';
		htm += '</td></tr></table>';
		htm += '</div>';
	}
	
	htm += '<table cellspacing=0 cellpadding=2 bgcolor=white>';
	htm += '    <tr>';
	htm += '        <td valign="top">';	
	
	htm += MainEventPropertyTable (dom);
	
	htm+= '          <hr noshade color="white">'; 
	
	panel.text      = ''; 
	panel.text     += Factory.create ('template','CommentTextbox','enabled', dis); 
	panel.width     = '500'; 
	panel.value     = 'comments'; 
	panel.name      = 'Comments'; 
	panel.content   = ''; 
	panel.state     = Localgetmode('comments') ? 'up' : 'down'; 
	if (Localgetmode('comments')) 
	{ 
	    panel.content+= '<table cellspacing=0 cellpadding=1 width=100%>'; 
	    for (var p in dom.EventComments)
	    {
		    ok=dom.SelectedComment==dom.EventComments[p].id; 
		    CommentText=dom.EventComments[p].CommentText; 
		    commenter.copy (dom.EventComments[p]);
		    commenter.bgcolor = ok?'white':'#f0f0f0';
		    if (CommentText) commenter.CommentText=ok?CommentText:(CommentText.substr(0,35) + (CommentText.length>35?'...':''));
		    panel.content += commenter.draw (); 
	    }
	    panel.content+= '</table>'; 
	}
	htm+= panel.draw();
	
	
	panel.content   = ''; 
	panel.text      = ''; 
	panel.text     += '<a href="javascript:window.currentevent.LaunchAttachmentWindow()" class=small>Add attachment...</a>'; 
	panel.width     = '500'; 
	panel.value     = 'attachments'; 
	panel.name      = 'Attachments'; 
	panel.state     = Localgetmode('attachments') ? 'up' : 'down'; 
	if (Localgetmode('attachments')) 
	{
		panel.content+= '<table cellspacing=0 cellpadding=1 width=100%>'; 
		for (var p in dom.Attachments)
		{ 
		    attacher.copy (dom.Attachments[p]);
		    panel.content += attacher.draw ();
		}
		panel.content+= '</table>';  
	}
	htm += panel.draw ();
	
	htm += '        </td>'; 
	
	
	htm += '        <td valign=top bgcolor=white width="100%">';
	
	panel.content   = ''; 
	panel.width     = '300'; 
	panel.text      = ''; 
	panel.value     = 'options'; 
	panel.name      = 'Options'; 
	panel.state     = Localgetmode('options')?'up':'down'; 
	if (Localgetmode('options'))
	{ 
        optionbody.copy ({
                        'user' : window.loggedinuser.id,
                        'featured' : dom.Featured?'checked':'',
                        'enabled' : dis,
                        'Attendees' : dom.Attendees || '0',
                        'approver' : dom.ApproveLogin && dom.ApproveLogin > 0 ? ( ' by ' + GetUserName (dom.ApproveLogin) ) : ' (not approved)',
                        'approved' : dom.ApproveLogin && dom.ApproveLogin > 0 ?'checked':'' 
                        });
	    panel.content+= optionbody.draw();  
	}
	htm += panel.draw ();
	 
	
	if( Controller.domClone )
	{
		// Conflicts table
		htm+= '<table width="300" class="bevelblue" id="panel_clone" cellspacing=0 cellpadding=5 bgcolor="#D0D0EE">'; 
		htm+= '<tr>';
		htm+= '<td><b>Clone Event</b></td>';
		htm+= '</tr>';
		htm+= '<tr>';
		htm+= '<td>'; 
		htm+= '<table>';   
		
		var starttime	= timeInput(Controller.domClone['EventStartTime']);
		var endtime		= timeInput(Controller.domClone['EventEndTime']);
		var date		= Controller.domClone['EventDate'];
		var key			= Controller.domClone['ID'];
		var rot			= Controller.domClone['RecurseType']||'-1';
				
		conflictor.copy ( Controller.domClone );
		conflictor.copy ({  'key' 		: dom['ID'], 
							'date' 		: date, 
							'css' 		: css, 
							'starttime' : starttime, 
							'endtime' 	: endtime , 
							'icon' 		: '' , 
				            'prepend' 	: 'CL' , 
							'conflicts' : '<div class=small style="color:gray">Enter event details and click Create</div>' + 
											'<input type="button" onclick="Controller.domClone.commit()" value="Create">' + 
											'<input type="button" onclick="cancelDOM()" value="Cancel">', 
							'EventDate' : dateInput(date) , 
							'display' 	: '' 
						   } ); 
		
		htm += conflictor.draw ();
		htm+= '</table>';  
		htm+= '</td>';
		htm+= '</tr>'; 
		htm+= '</table>';  
		htm+= '<hr noshade color="white">';
	}


	
	
	if( dom.Conflicts.length > 0)
	{
		// Conflicts table
		htm+= '<table width="300" class="bevelpink" id="panel_conf" cellspacing=0 cellpadding=5 bgcolor="#EECCCC">'; 
		htm+= '<tr>';
		htm+= '<td><b>Event Conflicts</b></td>';
		htm+= '</tr>';
		htm+= '<tr>';
		htm+= '<td>'; 
		htm+= '<table>'; 
		
		for (var p=0;p<dom.Conflicts.length;p++)
		{
			if (dom.Conflicts[p]['EventName'] && parseInt(dom.Conflicts[p]['ID'])!=parseInt(dom.ID))
			{
			    var starttime=timeInput(dom.Conflicts[p]['EventStartTime']);
			    var endtime=timeInput(dom.Conflicts[p]['EventEndTime']);
			    var date=dom.Conflicts[p]['EventDate'];
			    var key=dom.Conflicts[p]['ID'];
			    var rot=dom.Conflicts[p]['RecurseType']||'-1';
			    var conflicts=null;
			    try 
			    { conflicts=Controller.ConflictDates['cf-'+key]; 
			    } catch (ex) { }
			    var css=parseInt(rot)>=0?'font-weight:bold;':'';  
				 
				conflictor.copy (dom.Conflicts[p]);
				conflictor.copy ({
				                    'key' 		: key, 
				                    'date' 		: date, 
				                    'css' 		: css, 
				                    'starttime' : starttime, 
				                    'endtime' 	: endtime , 
				                    'icon' 		: '' , 
				                    'conflicts' : '' ,
				                    'prepend' 	: '' , 
				                    'EventDate' : dateInput(date) , 
				                    'display' 	: conflicts ? '' : 'none' 
				                   } ); 
				
				if (parseInt(rot)>=0)
				{
				    conflictor.icon += '<img title="Click here to see conflicting dates" onclick="'+(conflicts?'toggle(\'td-'+key+'\',\'ico-'+key+'\')':'LoadEventConflictDateRange('+key+')')+'"';
				    conflictor.icon += ' src="/webservices/images/'+(conflicts?'minus':'plus')+'.gif" id="ico-'+key+'" align=absmiddle>';
				}
				
				if (conflicts)
				{
				    for (var x in conflicts)
				    { 
				        checker.copy (conflicts[x]);
				        checker.key = key;
				        conflictor.conflicts += checker.draw();
				    }
				}
				htm += conflictor.draw ();
			} 
		}
		
		htm+= '</table>';  
		htm+= '</td>';
		htm+= '</tr>'; 
		htm+= '</table>';  
		htm+= '<hr noshade color="white">';
	}


	// Custom Properties table
	var name;
	var trail       = ','; 
	var chk         = '';
	panel.content   = ''; 
	panel.value     = 'properties'; 
	panel.name      = 'Custom Properties'; 
	panel.state     = Localgetmode('properties')?'up':'down'; 
	if (Localgetmode('properties'))
	{
		panel.content+= '<table>';  
		for (var p in window.properties)
		{
			if (trail.indexOf (window.properties[p].property_name) < 0)
			{ 
				chk='';
				for (var u in dom.CustomProperties) 
				{  
					if (dom.CustomProperties[u].name==window.properties[p].property_name) 
					{ 
						chk=dom.CustomProperties[u].value;  
						break; 
					} 
				}  
				panel.content += window.properties[p].draw (chk,dis);
			}
			trail += window.properties[p]['property_name'] + ',' 
		} 
		panel.content+= '</table>';    
	}
	htm+= panel.draw ();  

	
	panel.content   = ''; 
	panel.value     = 'categories'; 
	panel.name      = 'Categories'; 
	panel.state     = Localgetmode('categories')?'up':'down'; 
	if (Localgetmode('categories'))
	{ 
		for (var p in window.folders)
		{
	        chk = '';
			for (var u in dom.EventCategories) { if (dom.EventCategories[u].id==window.folders[p]['id']) { chk=' checked '; break; } }  
		    checkbox = { 'template' : 'checkbox',
	                      'checked' : chk,
	                      'enabled' : dis,
	                      'oncheck' : "AddorRemoveCategory('" + window.folders[p]['title'] + "','" + window.folders[p]['id'] + "', this.checked)",
	                      'label' : window.folders[p]['title'] 
	                     } ;  
			panel.content += Factory.write ( checkbox ); 
		}  
	}
	htm+= panel.draw (); 
	
	
	panel.content   = ''; 
	panel.value     = 'calendars'; 
	panel.name      = 'Calendars'; 
	panel.state     = Localgetmode('calendars')?'up':'down';  
	if (Localgetmode('calendars'))
	{ 
		for (var p in window.calendars)
		{
			name = window.calendars[p]['calendar_name'];
			if (name && name.length > 0)
			{
				chk='';
				for (var u in dom.EventCalendars) { if (dom.EventCalendars[u].id==window.calendars[p].id) {chk=' checked ';break; } }  
				checkbox = { 'template' : 'checkbox',
							  'checked' : chk,
							  'enabled' : dis,
							  'oncheck' : "AddorRemoveCalendar('" + p + "', this.checked)",
							  'label' : window.calendars[p]['calendar_name'] 
							 } ;  
				panel.content += Factory.write ( checkbox ); 
			}
		}  
	}  
	htm+= panel.draw (); 
		
	htm += '                    </td>';
	htm += '                </tr>';  
	htm += '                <tr>';
	htm += '                    <td>'; 
    htm += '                      <a href="javascript:void(0)" onclick="dialog(window.currentevent.Serialize())" class=small>View as XML</a>'; 
	htm += '                    </td>';
	htm += '                </tr>'; 
	htm += '            </table>'; 
	htm += '        </div>'; 
	htm += '        </td>'; 
	htm += '    </tr>'; 
	htm += '</table>';
	return htm;
}

function cancelDOM ()
{ 
	Controller.domClone = null;
	Controller.setvalue ('single_edit', null);
}

function cloneDOM (date)
{ 
	var dom = window.currentevent;
	Controller.domClone = EventObject.empty ( { cloneid : dom['ID'], clonedate : date } );
	for (var x in dom) Controller.domClone[x]=dom[x];
	Controller.domClone ['CustomDates'] 	= []; 
	Controller.domClone ['ID'] 				= 0; 
	Controller.domClone ['Recurring'] 		= 0; 
	Controller.domClone ['EventDate']   	= date;
	Controller.domClone ['RecurseEndDate'] 	= '';
	Controller.domClone ['RecurseType'] 	= '-1';
	Controller.domClone ['type'] 			= '-1';
	Controller.domClone ['RecurseUnit'] 	= '';
	
	 
	Controller.setvalue ('single_edit', date);
}

function MainEventPropertyTable (dom)
{ 
	var types=new Array ("Daily","Weekly","Monthly","Monthly","Yearly","On Weekdays","Unknown","Custom...");
	var suffi=new Array ("day","week","month","month","year","weekday","[???]","(custom)");
	var recurse_type=dom.RecurseType;
	var dis = window.http.readyState < ReadyState.DONE ? 'disabled' : '';
	var htm='';
	htm+= '<table cellspacing=0 id="property__main" class="bevelgreen" cellpadding=5 bgcolor="#D2E6D2" width="500">'; 
	htm+= '<tr>';
	htm+= '<td><b>What</b></td>';
	htm+= '<td>';
	htm+= '<input class=flat '+dis+' id="iEventName" datasrc="EventName" size=60 value="' + dom.EventName + '"';
	htm+= ' onchange="window.currentevent.EventName=this.value"></td>';
	htm+= '</tr>';
	
	htm+= '<tr>';
	htm+= '<td><b>Where</b></td>';
	htm+= '<td>';
	htm+= '<input class=roomselect '+dis+' id="iRoomName" datasrc="RoomName" size=60 value="' + dom.RoomName + '">';
	htm+= '</td>';
	htm+= '</tr>';
	

		
	htm+= '<tr>';
	htm+= '<td><b>When</b></td>';
	htm+= '<td nowrap>';
	htm+= '<input '+dis+' datasrc="EventDate" id="iEventDate" class=dateselect size=10 value="' + dateInput(dom.EventDate) + '"> ';
	
	htm+= ' Event: <input '+dis+' datasrc="EventStartTime" id="iEventStartTime" class=timeselect size=6 value="' + timeInput(dom.EventStartTime) + '"> to ';
	htm+= '<input '+dis+' datasrc="EventEndTime" id="iEventEndTime" class=timeselect size=6 value="' + timeInput(dom.EventEndTime) + '">'; 
	
	htm+= '</td></tr>';
	
	htm+= '<tr>';
	htm+= '<td><b>Repeats:</b></td>';
	htm+= '<td nowrap style="border-bottom:solid 1px #E0F1E0"> ';
	htm+= '<input '+dis+' datasrc="RecurseType" id="iRecurseType" ';
	htm+= ' class=rangeselect size=10 value="' + (dom.RecurseType>=0&&types[dom.RecurseType]?types[dom.RecurseType]:'Does not repeat') + '"><!---'+dom.RecurseType+'--->';
	
	
	htm+= ' Setup: <input '+dis+' datasrc="SetupStartTime" id="iSetupStartTime" class=timeselect size=6 value="' + timeInput(dom.SetupStartTime) + '"> to ';
	htm+= '<input '+dis+' datasrc="SetupEndTime" id="iSetupEndTime" class=timeselect size=6 value="' + timeInput(dom.SetupEndTime) + '">'; 
	
	
	
	htm+= '</td></tr>';
	htm+= ' ';
	
 
	if (dom.RecurseType>=0&&types[dom.RecurseType])
	{
		htm+= '<tr>';
		htm+= '<td>&nbsp;</td>';
		htm+= '<td style="border-bottom:solid 1px #E0F1E0">';
		
		
		htm+= '<table style="border:solid 1px black" bgcolor="#B0D4B0" cellpadding=5><tr><td>';
		htm += Calendar.scope (dom.EventDate, dom.RecurseEndDate, dom.RecurseType, dom.RecurseUnit);
	
		htm+= '</td></tr></table>';
		htm+= '</td>';
		htm+= '</tr>';
		
		
		htm+= '<tr>';
		htm+= '<td>&nbsp;</td>';
		htm+= '<td style="border-bottom:solid 1px #E0F1E0">';
		htm+= '<b>Repeat every:</b> ';
		htm+= '<input '+dis+' class=flat size=2 ';
		htm+= ' datasrc="RecurseUnit" ';
		htm+= ' value="' + dom.RecurseUnit + '"> ' + suffi[ dom.RecurseType ];
		htm+= dom.RecurseUnit==1?'':'s';
		htm+= '</td>';
		htm+= '</tr>';
		
		htm+= '<tr>';
		htm+= '<td>&nbsp;</td>';
		htm+= '<td style="border-bottom:solid 1px #E0F1E0">';
		htm+= '<b>Range:</b>'
		htm+= '<table cellpadding=2><tr>'; 
		htm+= '<td valign=top>Starts:</td>';
		htm+= '<td valign=top><input class=flat size=10 disabled value="' + dateInput(dom.EventDate) + '">';
		htm+= '<br>';
		htm+= '<a class="small" href="javascript:void(0)" onclick="ToggleDateListVisible()">';
		htm+= '' + (dom.DateListVisible?'Hide dates &#171;':'Show all dates &#187;') + '</a>';
		htm+= '</td>';
		htm+= '<td valign=top>Ends:</td>';
		htm+= '<td valign=top>';

		htm+= '<input '+dis+' class=dateselect datasrc="RecurseEndDate" id="iRecurseEndDate" size=10 value="' + dateInput(dom.RecurseEndDate) + '">';
		htm+= '<br>';
		if (dom.RecurseType < 7)
		{
			htm+= '<a class="small" href="javascript:void(0)" onclick="MakeDateScope()">';
			htm+= 'Recalculate date pattern ' + (dom.DateListVisible?'&#171;':'&#187;') + '</a>';
		}
		htm+= '</td>';
		htm+= '</tr></table>';
		
		
		htm+= '</td>';
		htm+= '</tr>';
		
		if (dom.DateListVisible)
		{ 
			htm+= '<tr>';
			htm+= '<td>&nbsp;</td>';
			htm+= '<td style="border-bottom:solid 1px #E0F1E0">'; 
			htm+= '<table cellpadding=2 cellspacing=0>'; 
			htm+= '<tr>'; 
			htm+= '<td>Event Dates <input type="button" value="Add Date" datasrc="CustomDate" id="iAdd" class="dateadder"></td>'; 
			htm+= '</tr>'; 
			htm+= '<tr><td>'; 
			htm+= '<div id="deventdateremove" style="background-color:#EFEFEF;height:100px;width:350px;overflow:auto;border:solid 1px;border-color:#666 #fff #fff #666">'; 
			htm+= '';
			var num=0,e = Factory.empty ('swaplink');
			for (var p in dom.CustomDates)
			{
				
				htm += '<input checked ';
				htm += 'onclick="';
				htm += 'var x=document.getElementById(\'deventdateremove\').scrollTop;';
				htm += 'window.currentevent.RemoveDate(\''+dom.CustomDates[p].value+'\');';
				htm += 'DebugEventDetailForm.invoke(); ';
				htm += 'document.getElementById(\'deventdateremove\').scrollTop=x;';
				htm += '" ';
				
				e.copy (dom.CustomDates[p]);
				e.key = dom.ID; 
				num++;
				 
				htm += ' type=checkbox>' + Factory.write (e) /*dom.CustomDates[p].title*/ + '<br>';
			}
			htm+= '</div>'; 
			htm+= '</td></tr></table>'; 
			htm+= '</td>';
			htm+= '</tr>';
		}
	}
	
	htm+= '<tr>';
	htm+= '<td valign=top>';
	if (dom.DescriptionVisible) htm+= '<a class="small" href="javascript:void(0)" onclick=\'ToggleFormVisible("DescriptionVisible")\'>Setup</a>'; 
	else htm+= '<b>Setup</b>';
	htm += '<br>';
	if (!dom.DescriptionVisible) htm+= '<a class="small" href="javascript:void(0)" onclick=\'ToggleFormVisible("DescriptionVisible")\'>Description</a>'; 
	else htm+= '<b>Description</b>';
	htm+= '</td>';
	htm+= '<td>';
	htm+= '<textarea '+dis+' class=flat datasrc="' + (dom.DescriptionVisible ? 'Description' : 'Comments') + '"';
	htm+= ' cols=45 rows=5>' + (dom.DescriptionVisible ? dom.Description : dom.Comments) + '</textarea></td>';
	htm+= '</tr>';
	/*	*/
	htm+= '</table>' ;
//	if ( Controller.single_edit )
//	{
//		htm += '[' + Controller.single_edit + ']';
//	}
	return htm;
}

function DataBinder (datasrc, element)
{
	element.onfocus = function () {  }
} 
   
function ToggleFormVisible(name)  
{  
    eval ('window.currentevent.' + name + '=!window.currentevent.' + name + ';');  
    DebugEventDetailForm.invoke();  
}     
   
function ToggleDateListVisible()  
{  
    ToggleFormVisible ('DateListVisible'); 
}     
 
function ToggleFeaturedValue (gridid, eventid, value)  
{   
    var dw=getElement ('dworkspace');    
    var dg=window.datagrids[gridid];  
    for (var row=0;row<dg.rows.length;row++)  
    {    
        if (dg.rows[row]['ID']==eventid)  
        {  
            dg.rows[row]['Featured'] = value;   
            dw.innerHTML=dg.draw();  
            LoadFeaturedValueRequest (eventid, value);  
            break;  
        }  
    }  
}  

function MakeDateScope ()  
{   
    var dom=window.currentevent;  
    var s1 = dateUK (dom.EventDate);  
    var s2 = dateUK (dom.RecurseEndDate);  
    var tp = dom.RecurseType;  
    var ui = dom.RecurseUnit;  
    LoadDateScope (s1,s2,tp,ui);  
}  

function RequestCreateCategory ()  
{  
    var name = prompt("Enter a name for the new category","New category");  
    if (name) CreateCategory (name);  
} 

function  OnConflictDatesReceive ()
{  
    var result = [];
    for (var x in this.target)
    {   
        result.push ( new CustomDate (this.target[x]['FriendlyDate'], this.target[x]['CustomDate']) );  
    }
    Controller.ConflictDates['cf-' + this.params.id] = window.currentevent.MatchDates (result);  
    Controller.Reload('dcevent');       
}  

var swaplink = '';
swaplink += '<a href="javascript:void(0)" id="ai-(key)-(value)" ';
swaplink += ' onclick="cloneDOM(\'(value)\');';
//swaplink += 'DisplayDateSelector';
//swaplink += '(\'ai-(key)-(value)\', \'(value)\', function() {SwapEventCustomDate(this.getvalue(), \'(value)\', (key))}, [\'deventdateremove\',\'dcevent\'])';
swaplink += '"';
swaplink += '>(title)</a>';   

var optionpanel = '' 
optionpanel+= '<table width="(width)" id="panel__(value)" class="bevelgray" cellspacing=0 cellpadding=5 bgcolor="#EEEEEE">'; 
optionpanel+= '<tr>';
optionpanel+= '<td><b>(name)</b></td>';
optionpanel+= '<td>(text)</td>';
optionpanel+= '<td align="right"><a ';
optionpanel+= ' onclick="Controller.setmode(\'(value)\')" ';
optionpanel+= ' href="javascript:void(0)" style="text-decoration:none;color:black"';
optionpanel+= ' ><img src="/webservices/images/explorer/ico_hide_button_(state)_off.gif"></a></td>'; 
optionpanel+= '</tr>'; 
optionpanel+= '<tr><td colspan="3" class="optionpanel">'; 
optionpanel+= '(content)'; 
optionpanel+= '</td></tr>'; 
optionpanel+= '</table>'; 
optionpanel+= '<hr noshade color="white">';



var AttachmentRow = '';
AttachmentRow += '<tr>'; 
AttachmentRow += '<td class=datarow bgcolor="#ffffff" >'; 
AttachmentRow += '<input type=checkbox checked onclick="DeleteAttachment((id))">';  
AttachmentRow += '</td>';  
AttachmentRow += '<td nowrap class=datarow bgcolor="#ffffff">';  
AttachmentRow += '<a class=small target="_blank" href="eb-upload.php?id=(id)" style="color:blue">(attachment_name)</a>';  
AttachmentRow += '</td>'; 
AttachmentRow += '<td class=datarow bgcolor="#ffffff">'; 
AttachmentRow += '<div class=small>&nbsp;(attachment_type)</div>'; 
AttachmentRow += '</td>'; 
AttachmentRow += '<td class=datarow bgcolor="#ffffff" nowrap>'; 
AttachmentRow += '<div class=small align="right" >&nbsp;(attachment_size) bytes</div>'; 
AttachmentRow += '</td>'; 
AttachmentRow += '<td class=datarow bgcolor="#ffffff" width="100%">'; 
AttachmentRow += '&nbsp;</td>'; 
AttachmentRow += '</tr>'; 


var CommentRow = '';
CommentRow += '<tr>'; 
CommentRow += '<td class=datarow bgcolor="(bgcolor)"  style="cursor:hand" '; 
CommentRow += 'onclick="'; 
CommentRow += 'var sc=window.currentevent.SelectedComment;'; 
CommentRow += 'window.currentevent.SelectedComment=sc==(id)?-1:(id);'; 
CommentRow += 'DebugEventDetailForm.invoke();'; 
CommentRow += '">'; 
CommentRow += '(FullName)'; 
CommentRow += ' - <font color=gray>(CommentText)</font>'; 
CommentRow += '</td>';
CommentRow += '<td class=datarow bgcolor="(bgcolor)" nowrap>'; 
CommentRow += '<small>(CommentDate)</small>';  
CommentRow += '</td>';
CommentRow += '</tr>'; 


var CommentTextbox = '';
CommentTextbox+= '&nbsp;&nbsp;<input (enabled) size=40 id="iComments" class="commentstring" ';
CommentTextbox+= 'onfocus="';
CommentTextbox+= 'this.value=\'\';';
CommentTextbox+= 'this.style.color=\'black\';';
CommentTextbox+= '"'; 
CommentTextbox+= 'onblur="';
CommentTextbox+= 'if (this.value!=\'\') { window.currentevent.AddComment(this.value) ; DebugEventDetailForm.invoke(); }';
CommentTextbox+= 'this.style.color=\'gray\';';
CommentTextbox+= 'this.value=\'Type here to add a comment\';';
CommentTextbox+= '"'; 
CommentTextbox+= 'value="Type here to add a comment">'; 

//Conflictbox += '<tr>';
//Conflictbox += '<td style="(css)font-size:9pt">';
//Conflictbox += '<img src="/webservices/images/explorer/alerticon.jpg" style="margin:1px" align="absmiddle">';
//Conflictbox += '(icon)</td>';
//Conflictbox += '<td style="(css)font-size:9pt;color:#0000FF">(EventName)</td>';
//Conflictbox += '</tr>';

var Conflictbox = '';
Conflictbox += '<tr>';
Conflictbox += '<td style="(css)font-size:9pt">';
Conflictbox += '<img src="/images/news.gif_workcopy.PNG" style="margin:1px" align="absmiddle">';
Conflictbox += '(icon)</td>';
Conflictbox += '<td style="(css)font-size:9pt;color:#0000FF">(EventName)</td>';
Conflictbox += '</tr>';
Conflictbox += '<tr>';
Conflictbox += '<td style="font-size:9pt"></td>';
Conflictbox += '<td style="font-size:9pt">';
Conflictbox += ' on <a href="javascript:void(0)" id="a-(key)-(date)" ';
Conflictbox += ' title="This is the date of the event and may or may not be conflicting. Click here to change the date of';
Conflictbox += ' this event or click the + icon to see the conflicting dates"';
Conflictbox += ' onclick="(prepend)DisplayDateSelector(\'a-(key)-(date)\', \'(date)\', function() {ResetEventConflictDate(this.getvalue(), (key))})"';
Conflictbox += '>(EventDate)</a>'; 
Conflictbox += ' in <a href="javascript:void(0)" id="ac-(key)" onclick="(prepend)LoadEventConflictRoomList (\'(key)\')">(RoomName)</a>'; 
Conflictbox += '</td>';
Conflictbox += '</tr>';
Conflictbox += '<tr>';
Conflictbox += '<td style="font-size:9pt"></td>';
Conflictbox += '<td style="font-size:9pt"> from ';
Conflictbox += '<a href="javascript:void(0)" id="t1-(key)-(date)" ';
Conflictbox += ' onclick="(prepend)DisplayTimeSelector(\'t1-(key)-(date)\', \'(starttime)\', (key), \'Start\')"';
Conflictbox += '>(starttime)</a>'; 
Conflictbox += ' to '; 
Conflictbox += '<a href="javascript:void(0)" id="t2-(key)-(date)" ';
Conflictbox += ' onclick="(prepend)DisplayTimeSelector(\'t2-(key)-(date)\', \'(endtime)\', (key), \'End\')"';
Conflictbox += '>(endtime)</a>'; 
Conflictbox += '</td>';
Conflictbox += '</tr>';
Conflictbox += '<tr>';
Conflictbox += '<td style="font-size:9pt"></td>';
Conflictbox += '<td style="display:(display)" id="td-(key)" style="font-size:9pt">(conflicts)</td>';
Conflictbox += '</tr>';


 
var Conflictcheck = '';
Conflictcheck += '<input onclick="';
Conflictcheck += 'if (confirm(\'Remove (title)?\')) { RemoveCustomDateLink(\'(key)\',\'(value)\') } else this.checked=true;';
Conflictcheck += '" type="checkbox" checked>';
Conflictcheck += '<a href="javascript:void(0)" id="ai-(key)-(value)" ';
Conflictcheck += ' onclick="';
Conflictcheck += 'DisplayDateSelector';
Conflictcheck += '(\'ai-(key)-(value)\', \'(value)\', function() {SwapEventConflictDate(this.getvalue(), \'(value)\', (key))})';
Conflictcheck += '"';
Conflictcheck += '>(title)</a>';   
Conflictcheck += '<br>';


var optioncontent = ''
optioncontent+= '<table>'; 
optioncontent+= '<tr>';
optioncontent+= '<td style="color:#666">';
optioncontent+= '<input value="(user)"';
optioncontent+= ' id="iApproveLogin" datasrc="ApproveLogin"';
optioncontent+= ' type=checkbox (approved)';
optioncontent+= '>Approved';
optioncontent+= ' (approver) ';
optioncontent+= '</td>';
optioncontent+= '</tr>';
optioncontent+= '<tr>';
optioncontent+= '<td><input value="1" id="iFeatured" datasrc="Featured"';
optioncontent+= ' type=checkbox (featured)';
optioncontent+= '>Featured</td>';
optioncontent+= '</tr>';
optioncontent+= '<tr>';
optioncontent+= '<td>Attendees: <input size=4 (enabled) id="iAttendees"';
optioncontent+= ' datasrc="Attendees" value="(Attendees)"></td>';
optioncontent+= '</tr>'; 
optioncontent+= '</table>'; 